package com.googlecode.wstester.handlers

import actors.Actor
import utils.Send
import org.apache.commons.httpclient.methods.PostMethod
import org.apache.commons.httpclient.HttpClient

/**
 * Created by IntelliJ IDEA.
 * User: pablo
 * Date: 2010-07-05
 * Time: 12:20:20
 */

class RequestHandler(message: String) extends Actor {
  var targetURL = "";
  var soapAction = "";
  def act() = {
    receive {
      case Send => {
        var post = new PostMethod(targetURL);
        post.setRequestHeader("SOAPAction", soapAction);
        post.setRequestHeader("Content-Type:", "text/xml; charset=\"utf-8\"");
        post.setRequestBody(message);
        var client = new HttpClient();
        client.executeMethod(post);
        println(post.getResponseBodyAsString);
      }
    }
  }
}